package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
public class NursingLevelController {
      @Autowired
private NursingLevelService nursingLevelService;
     @GetMapping("/listAll")
      @ApiOperation("查询所有护理等级接口")
      public ResponseResult<List<NursingLevelVo>> getAll(){
           List< NursingLevelVo> nursinglvevelDtos=  nursingLevelService.getAll();
            return ResponseResult.success(nursinglvevelDtos);
      }

      @GetMapping("/listByPage")
      @ApiOperation("条件分页查询")
        public ResponseResult<PageResponse<NursingLevelVo>>listByPage(Integer pageNum,Integer pageSize,String name,Integer status ){
         PageResponse<NursingLevelVo> nursingLevelDtos=nursingLevelService.listByPage(pageNum,pageSize,name,status);
         return ResponseResult.success(nursingLevelDtos);

        }
        //新增护理等级
        @PostMapping("/insert")
        @ApiOperation("新增护理等级条目")
        public ResponseResult insert(@RequestBody NursingLevelDto nursingLevelDto) {
            nursingLevelService.insert(nursingLevelDto);
            return ResponseResult.success(nursingLevelDto);
        }

    //根据ID查询护理条目
    @GetMapping("/{id}")
    @ApiOperation("根据ID查询条目")
    public ResponseResult getById(@PathVariable("id") Long id) {
        NursingLevel nursingLevel = nursingLevelService.getById(id);
        return ResponseResult.success(nursingLevel);
    }

    //修改护理条目
    @PutMapping("/update")
    @ApiOperation("修改护理等级条目")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.update(nursingLevelDto);
        return ResponseResult.success();
    }
    //删除护理等级
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除护理等级")
    public ResponseResult delete(@PathVariable("id") Long id) {
         nursingLevelService.delete(id);
        return ResponseResult.success();
    }
}
